package cnsatmsmart.automation.mmi.view.dialogs;

import cnsatmsmart.automation.mmi.helper.utilities.GlobalEnvVars;
import java.awt.Color;
import java.awt.Image;
import javax.swing.JDialog;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author SIK - PTIK, BPPT
 */
public class listFlightView extends JDialog
{
    /* atribut-atribut yang dimiliki oleh kelas listFlightView */
        DefaultTableModel model;
        JTable table;

    /**
     * constructor - user define constructor, no default constructor
     */
        public listFlightView()
        {
            Image frameIcon = GlobalEnvVars.kit.getImage(getClass().getResource("/cnsatmsmart/resources/"+GlobalEnvVars.icon));
            setIconImage(frameIcon);
            setTitle("Flight List");
            setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
            setSize((int)(GlobalEnvVars.screenWidth*3/4), (int)(GlobalEnvVars.screenHeight/3));
            setAlwaysOnTop(true);

            String[] columnNames = {"Status",
                                "State",
                                "Code",
                                "Call Sign",
                                "Flag",
                                "Country",
                                "Latitude (deg)",
                                "Longitude (deg)",
                                "Altitude (fl)",
                                "Vertical Rate",
                                "Track Angle (deg)",
                                "Ground Speed",
                                "Last Update",
                                "Time of Day"};
            model = new DefaultTableModel(columnNames, 0);
            table = new JTable( model )
            {
                //  mengembalikan kelas dari setiap kolom
                //  renderers yang digunakan bergantung pada kelas masing-masing
                @Override
                public Class getColumnClass(int column)
                {
                    return getValueAt(0, column).getClass();
                }

                @Override
                public boolean isCellEditable(int rowIndex, int colIndex) {
                   return false; //tiap cell dari tabel tidak dapat diedit
                }
            };
            table.setBackground(Color.CYAN);
            table.setPreferredScrollableViewportSize(table.getPreferredSize());
            table.getTableHeader().setReorderingAllowed( false );

            JScrollPane scrollPane = new JScrollPane( table );
            getContentPane().add( scrollPane );
        }

    /* getter */
        /**
         * mengembalikan nilai dari atribut model
         * @return DefaultTableModel
         */
        public DefaultTableModel getModel()
            {return model;}

        /**
         * mengembalikan nilai dari atribut table
         * @return JTable
         */
        public JTable getTable()
            {return table;}
}